home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9737 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  31 lines

  1. Path: news.netam.net!alpha!bgc
  2. From: bgc@alpha.netam.net (The Bowling Green Connection)
  3. Newsgroups: comp.lang.c
  4. Subject: HELP! Modifying the EOF in a file!
  5. Date: 13 Mar 1996 01:25:08 GMT
  6. Organization: NetAmerica, Bowling Green, KY.
  7. Message-ID: <4i585k$4ia@news.netam.net>
  8. NNTP-Posting-Host: alpha.netam.net
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. I am having trouble shortening the size of a text file...
  12. Suppose I have a text file with 3 lines of data, then I
  13. run this program:
  14.  
  15. void main() {
  16.    FILE *dat;
  17.    dat=fopen("file.txt", "r+");
  18.    fprintf(dat, "Hello! %c", EOF);
  19.    fclose(dat);
  20. }
  21.  
  22. Why doesn't the EOF character chop off the remaining two lines?
  23. When I print out the file after running this program, the ONLY thing
  24. that changed was the first few characters.. The other two lines
  25. still remain..  HELP!
  26.  
  27. _______________________________________________________________________________
  28. Edgar E. Easterly, IV   (bgc@bgcky.com)   Bowling Green, Kentucky         -=O=-
  29. "Except the Lord build thy house, ye labour in vain that build it; Except   *
  30. the Lord keep thy city, the watchman will awake but in vain." Psalms 127:1  |
  31.